/*
 * @lc app=leetcode.cn id=94 lang=javascript
 *
 * [94] 二叉树的中序遍历
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number[]}
 */
var inorderTraversal = function(root) {
    
};
// @lc code=end

function threeOrders( root ) {
    // write code here
    function pre_dfs(node) {
        if (!node) return []
        let ans = [node.val]
        ans.concat(pre_dfs(node.left))
        ans.concat(pre_dfs(node.right))
        return ans
    }
    function in_dfs(node) {
        if (!node) return []
        let ans = in_dfs(node.left)
        ans.push(node.val)
        ans.concat(in_dfs(node.right))
        return ans
    }
    function post_dfs(node) {
        if (!node) return []
        let ans = post_dfs(node.left)
        ans.concat(post_dfs(node.right))
        ans.push(node.val)
        return ans
    }
    return [pre_dfs(root), in_dfs(root), post_dfs(root)]
}
function TreeNode(val, left, right) {
    this.val = (val===undefined ? 0 : val)
    this.left = (left===undefined ? null : left)
    this.right = (right===undefined ? null : right)
}
let root = new TreeNode(1)
root.left = new TreeNode(2)
root.right = new TreeNode(3)

let ans = threeOrders(root)
console.log(ans)